<template>
  <div class="container">
    <el-row>
      <el-col :span="24" align="left">
        <el-button type="primary" @click="addApp">添加应用包</el-button>
      </el-col>
    </el-row>

    <!-- table start -->
    <el-table ref="table" class="table-wrap" stripe empty-text fit tooltip-effect="dark" :data="tableData">
      <el-table-column align="center" prop="id" label="ID"></el-table-column>
      <el-table-column align="center" prop="versionname" label="版本名称"></el-table-column>
      <el-table-column align="center" prop="versioncode" label="版本CODE"></el-table-column>
      <el-table-column align="center" prop="uri" label="标识"></el-table-column>
      <el-table-column align="center" prop="forceupdate" label="是否强制更新" :formatter="forceupdateFormatter"></el-table-column>
      <el-table-column align="center" prop="status" label="状态" :formatter="statusFormatter"></el-table-column>
      <el-table-column align="center" prop="createdate" label="创建时间" :formatter="createdateFormatter"></el-table-column>
    </el-table>
    <!-- table end -->
    <!-- 添加pda dialog start -->
    <handlePdaPopup
      v-if="handlePdaPopupVisible"
      :popupVisible="handlePdaPopupVisible"
      @callback="getData"
      @close="handlePdaPopupVisible=false"
    ></handlePdaPopup>
    <!-- 添加pda dialog end -->
  </div>
</template>
<script>
export default {
  name:'PDA',
  data(){
    return {
      handlePdaPopupVisible:false, // 控制选择库位dialog显示隐藏

      tableData:[]
    }
  },
  mounted(){
    this.getData()
  },
  components:{
    handlePdaPopup:() => import('@/components/pda/handle-pda-popup')
  },
  methods:{
    getData(){
      let options = {
        method:'get',
        url:`/pdaversion/latest`
      }
      this.$axios(options).then(({ data }) => {
        this.tableData = [data]
      })
    },
    addApp(){
      this.handlePdaPopupVisible = true
    },
    // 表格过滤项
    forceupdateFormatter(row){
      return ['否','是'][row.forceupdate]
    },
    statusFormatter(row){
      return ['禁用','启用'][row.status]
    },
    createdateFormatter(row){
      return row.createdate.replace(/T/g,' ').substring(0,row.createdate.indexOf('.'))
    }
  }
}
</script>
<style lang="scss" scoped>

</style>